program Newsort1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
 n,i,j,x:integer;
 fin:textfile;
 a: array of integer;

begin
 assignfile(fin,'input.txt');
 reset(fin);
 readln(fin, n);
 setlength(a, n);
  for i:=1 to n do
  begin
    read(fin,a[i]);
  end;
    for j:=1 to (n) do
      for i:=0 to (n-j) do
        if (a[i]>a[i+1]) then
  begin
   x:=a[i];
   a[i]:=a[i+1];
   a[i+1]:=x;
  end;
  writeln(a[1]+a[n]);
  readln;
  closefile(fin);
end.
 